<?php

namespace teia\webdev\php\cust;

$inc_lib = realpath(dirname(__FILE__) . '/../../teia.lib/inc/inc_core.inc');
require_once $inc_lib;
use teia\webdev\php\core as teia;

class CustFunctions {
	
	static function include_cust_page($page, $var_array=NULL, $require=TRUE, $once=FALSE) {
		$inc_path = realpath(dirname(__FILE__) . '/../pages/' . $page);
		if ($var_array) {
			foreach ($var_array as $key => $value) {
				$$key = $value;
			}
		}
		if ($require) {
			if ($once) {
				require_once $inc_path;
			} else {
				require $inc_path;
			}
		} else {
			if ($once) {
				include_once $inc_path;
			} else {
				include $inc_path;
			}
		}
	}
	
	static function display_err_msg($err_msg) {
		if (!empty($err_msg)) {
			echo '	<div class="err_msg" style="text-align:center; border-style:solid; border-width:medium; border-color:red; display:block;">
						<p id="err_msg"> Error: ' . $err_msg . '</p>
					</div>' . "\n";
		}
	}
	
	static function display_header_logo($var_array=NULL) {
		self::include_cust_page('logo_header.php', $var_array);
	}
	
	static function display_top_nav($var_array=NULL) {
		self::include_cust_page('top_nav.php', $var_array);
	}
	
	static function display_page_header($header_logo_vars=NULL, $top_nav_vars=NULL) {
		display_header_logo($header_logo_vars);
		display_top_nav($top_nav_vars);
	}	
	
	static function display_menu($var_array = NULL) {
		self::include_cust_page('menu.php', $var_array);
	}
	
	static function display_gender_submenu($var_array = NULL) {
		self::include_cust_page('gender_submenu.php', $var_array);
	}
	static function display_top_banner($var_array=NULL) {
		self::include_cust_page('top_banner.php', $var_array);
	}
	
	static function display_cust_header($var_array) {
		if ($var_array) {
			foreach ($var_array as $key => $value) {
				$$key = $value;
			}
		}
		// header
		self::include_header($var_array);
		self::include_cust_page('logo_header.php', $var_array);
		self::include_cust_page('top_nav.php', $var_array);
		self::include_cust_page('menu.php', $var_array);
	}
	
	static function display_footer($var_array=NULL) {
		self::include_cust_page('footer.php' ,$var_array);
	}
	
	static function include_html_head($var_array=NULL) {
		if ($var_array) {
			foreach ($var_array as $key => $value) {
				$$key = $value;
			}
		}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
		<title><?php echo $title; ?></title>
		<link href="layout.css" rel="stylesheet" type="text/css">
		<link href="style01.css" rel="stylesheet" type="text/css">
		<link href="style_slideshow.css" rel="stylesheet" type="text/css">
		<?php teia\FunctionPool::include_jquery(); ?>
		<style type="text/css">
			.auto-style1 {
				margin-left: 0;
			}
		</style>
	</head>
<?php
	}
	
	static function include_simple_html_head($var_array=NULL) {
		if ($var_array) {
			foreach ($var_array as $key => $value) {
				$$key = $value;
			}
		}
		?>
	<!DOCTYPE html>
	<html>
		<head>
			<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
			<title><?php echo $title; ?></title>
			<?php teia\FunctionPool::include_jquery(); echo "\n"; ?>
		</head>
	<?php
	}
		
	static function include_header($var_array=NULL) {
		if ($var_array) {
			foreach ($var_array as $key => $value) {
				$$key = $value;
			}
		}
		self::include_html_head($var_array);
	?>
		<body>
			<div align="center" style="position: absolute; margin-left: inherit; margin-right: inherit">
		
	<?php	
	}
	
	static function include_cust_footer($var_array=NULL) {
		if ($var_array) {
			foreach ($var_array as $key => $value) {
				$$key = $value;
			}
		}
?>
			<div id="footer">
				<img src="imagens_tabs/tab04_footer.gif" />	
			</div>
		</div>
		<script src="homem/jquery.min.js"></script>
		<script src="script.js"></script>
		<script src="autoadvance.js"></script>
	</body>
</html>

<?php
	}
}

?>